//
//  YeeShopCarVC.m
//  YeeShopProject
//
//  Created by CoderYee on 2017/3/3.
//  Copyright © 2017年 CoderYee. All rights reserved.
//

#import "YeeShopCarVC.h"
#import "YeeShopDetailVC.h"
#import "YeeCarSectionView.h" //sectionView
#import "YeeCarViewModel.h"
#import "YeeShopCarTableViewCell.h" //cell
#import "YeeCouponPopView.h"
#import "YeeShopCarBottomView.h"
#import "YeeShopStoreVC.h" //店铺
#import "YeePopCover.h" //遮罩
#import "UIView+YeeViewAnimation.h"
@interface YeeShopCarVC ()
{
    
}
@property(nonatomic,retain)YeeShopCarBottomView *bottomView;

@end

@implementation YeeShopCarVC

- (void)viewDidLoad
{
    [super viewDidLoad];
}

-(void)addOwnViews
{
    [super addOwnViews];
    [self.view addSubview:self.bottomView];
}
-(void)addNavbarView
{
    [super addNavbarView];
    self.navigationItem.rightBarButtonItem=[UIBarButtonItem itemWithBtnTitle:@"详情" target:self action:@selector(pushtoGoodVc)];
}
-(void)configOwnViews
{
    [super configOwnViews];
    [self.tableView setFrame:CGRectMake(0, 0, kMainScreenWidth, kcontentViewHeight-49-40)];
    self.tableView.showsVerticalScrollIndicator=NO;
    self.tableView.showsHorizontalScrollIndicator=NO;
    [self.view setBackgroundColor:xBackgroundColor];
    [self.tableView setBackgroundColor:xBackgroundColor];
}
-(void)bindViewModel
{
    [super bindViewModel];
}
-(YeeShopCarBottomView*)bottomView
{
    if (_bottomView==nil)
    {
      _bottomView=[[YeeShopCarBottomView alloc] initWithFrame:CGRectMake(0, kcontentViewHeight, kMainScreenWidth, 40)];
        [_bottomView setBackgroundColor:kWhiteColor];
        [UIView animateWithDuration:0.05 animations:^{
            [_bottomView setFrame:CGRectMake(0, kcontentViewHeight-40-49, kMainScreenWidth, 40)];
        }];
    }
    return _bottomView;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 5;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 5;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    YeeShopCarTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:NSStringFromClass([YeeShopCarTableViewCell class])];
    if (cell==nil)
    {
        cell=[[YeeShopCarTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([ YeeShopCarTableViewCell class])];
    }
    return cell;
}

-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    YeeCarSectionView *headerview=[[YeeCarSectionView alloc] initWithFrame:CGRectMake(0, 0, kMainScreenWidth, 40)];
    headerview.section=section;
    [headerview setBackgroundColor:kWhiteColor];
    [headerview.clickSubject subscribeNext:^(id  _Nullable x)
     {
         YeeCouponPopView *PopView=[[YeeCouponPopView alloc] initWithFrame:[UIScreen mainScreen].bounds];
         [[UIApplication sharedApplication].keyWindow addSubview:PopView];
         
    }];
    return headerview;
}
-(UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    UIView *view=[[UIView alloc] init];
    return view;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 40;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0.01;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return 130;
}
#pragma mark --点击单元格
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    YeeShopStoreVC  *storeVC=[[YeeShopStoreVC alloc] init];
    storeVC.hidesBottomBarWhenPushed=YES;
    [self.navigationController pushViewController:storeVC animated:YES];
}

-(void)pushtoGoodVc
{
    
//    UIView  *maskView=[[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
//    [maskView setBackgroundColor:kRedColor];
//    [[YeePopCover shareManger] setBackgroundColor:kBlueColor];
//    [[YeePopCover shareManger] PopMaskView:maskView InView:self.view animations:^{
//        
//        [maskView addBaseSpringAnimationType:YeeFromTopType Duration:0.8 completion:^(BOOL finished)
//        {
//            
//        }];
//    } ClickBlock:^{
//        
//        
//    }];
    
    YeeShopDetailVC *detailVc= [YeeShopDetailVC new];
    detailVc.hidesBottomBarWhenPushed=YES;
     [self.navigationController pushViewController:detailVc animated:YES];
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
